<?php	
	require_once(dirname(__FILE__).'/class/Cliente.php');
	
	$objConnection = new Connection();
	$objCliente = new Cliente();
	$objCliente->Logado();

?>

<!DOCTYPE html>
<html lang="pt-br">
<head>
	<meta charset="utf-8">
	<title>Entendo a estrutura e semântica do HTML5</title>
	<meta name="keywords" content="HTML5, CSS3, frontend, agni">
	<meta name="description" content="Se você quer se aventurar com o HTML5, entenda aqui a sua estrutura básica, a semântica das principais marcações novas e algumas ferramentas.">
	<meta name="author" content="Edu Agni">
	<meta name="robots" content="index,follow">
	<link rel="stylesheet" type="text/css" href="css/login.css">
	<script src="js/login.js"></script>

	<!-- BOOTSTRAP -->
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

	<!-- Optional theme -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">

	<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>

	<!-- Latest compiled and minified JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
	<!-- BOOTSTRAP -->

</head>
<body>

	<!-- Modal -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog modal-cadastre">
			<div class="modal-content">
				<div class="modal-header cadastre">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">Cadastre-se</h4>
				</div>
				<div class="modal-body body-cadastre">
					<form action="" method="POST">
						<input type="text" name="nome" placeholder="Nome" required />
						<input type="text" name="sobrenome" placeholder="Sobrenome" required />
						<input type="text" name="cpf" placeholder="CPF" required />
						<input type="text" name="email" placeholder="E-mail" required />
						<input type="text" name="telefone" placeholder="Telefone" required />
						<input type="text" name="usuario" placeholder="Usuário" required />
						<input type="password" name="senha" placeholder="Senha" required />
				</div>
				<div class="modal-footer">
					<!--<button type="button" class="btn btn-success cadastre">Cadastrar</button>-->
					<input type="submit" class="btn btn-success cadastre" name="Cadastrar" value="Cadastrar" />
					</form>

					<?php
					if(isset($_POST["Cadastrar"]) && $_POST["Cadastrar"] == "Cadastrar"){
						$objCliente->CadastrarCliente($_POST["nome"],$_POST['sobrenome'],$_POST['cpf'],$_POST['email'],$_POST['telefone'],$_POST['usuario'],MD5($_POST['senha']));
					}
					?>

				</div>
			</div>
		</div>
	</div>


	<div class="container">
		<div class="login-container">
			<div id="output"></div>
			<div class="avatar"></div>
			<div class="form-box">
				<form action="" method="POST">
					<input name="usuario" type="text" placeholder="Usuário">
					<input type="password" name="senha" placeholder="Senha">
					<button class="btn btn-info btn-block login" name="Enviar" value="Enviar" type="submit">Login</button>
					<button type="button" class="btn btn-success cadastre" data-toggle="modal" data-target="#myModal">Cadastre-se</button>
				</form>

				<?php
					if(isset($_POST["Enviar"]) && $_POST["Enviar"] == "Enviar"){
						$logar = $objCliente->Logar($_POST["usuario"],MD5($_POST['senha']));
					}
					?>
					<br />
					<?php 
					if (isset($logar)){
					?>
						<div class="container-erro">
							<?php echo $logar ?>
						</div>
				<?php } ?>

			</div>
		</div> 
	</div>   
</body>
</html>